package edu.java.texbooks.scjp.collections.test03.comparison.collections;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class TestDVD {

	static DVDInfo dvd1 = new DVDInfo("Donnie Darko", "sci-fi",
			"Gyllenhall,Jake");
	static DVDInfo dvd2 = new DVDInfo("Raiders of the Lost Ark", "action",
			"Ford,Harrison");
	static DVDInfo dvd3 = new DVDInfo("2001", "sci-fi", "");
	static DVDInfo dvd4 = new DVDInfo("Caddy Shack", "comedy", "Murray, Bill");
	static DVDInfo dvd5 = new DVDInfo("Star Wars", "sci-fi", "Ford, Harrison");
	static DVDInfo dvd6 = new DVDInfo("Lost in Translation", "comedy",
			"Murray, Bill");
	static DVDInfo dvd7 = new DVDInfo("Patriot Games", "action",
			"Ford, Harrison");

	public static void main(String[] args) {

		ArrayList<DVDInfo> listDVD = new ArrayList<DVDInfo>();
		listDVD.add(dvd1);
		listDVD.add(dvd2);
		listDVD.add(dvd3);
		listDVD.add(dvd4);
		listDVD.add(dvd5);
		listDVD.add(dvd6);
		listDVD.add(dvd7);
		ArrayList<DVDInfo> copyListDVD = new ArrayList<DVDInfo>(listDVD);
		System.out.println(listDVD);

		// try to sort
		Collections.sort(listDVD);
		System.out.println(listDVD);

		DVDComperator comparator = new DVDComperator();

		System.out.println("------ Apply comparator -----------\n\n");
		System.out.println(copyListDVD);
		Collections.sort(copyListDVD, comparator);
		System.out.println("\n\n");
		System.out.println(copyListDVD);
	}
}
